﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="微信">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <title>幸运大转盘活动开始了（demo演示不要当真） 幸运大转盘抽奖</title>

    <link href="css/activity-style2.css" rel="stylesheet" type="text/css">
    <style>
        .activity-lottery-winning
        {
            background: url(http://bcs.duapp.com/baeimg/3Ti0TElmeu.gif) repeat scroll 0 0 #7E65AB;
            background-size: 120px auto;
            overflow: hidden;
        }
    </style>
</head>

<body class="activity-lottery-winning">

    <div class="main">

        <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js" type="text/javascript"></script>
        <script src="../../scripts/jquery/alert.js" type="text/javascript"></script>
        <div id="outercont">
            <div id="outer-cont">
                <div id="outer">
                    <img src="images/zp8-.png">
                </div>
            </div>
            <div id="inner-cont">
                <div id="inner">
                    <img src="images/activity-lottery-2.png">
                </div>
            </div>
        </div>
        <div class="content">
            <div class="boxcontent boxwhite" id="result" style="display: none">
                <div class="box">
                    <div class="title-orange"><span>恭喜你中奖了</span></div>
                    <div class="Detail">

                        <p>你中了：<span class="red" id="prizetype">   </span></p>
                        <p>兑奖SN码：<span class="red" id="sncode"></span></p>
                        <p class="red" id="red">本次兑奖码已经关联你的微信号，你可向公众号发送【新大转盘】进行查询!  </p>
                        <p>
                            <input name="" class="px" id="tel" value="" type="text" placeholder="用户请输入您的手机号">
                        </p>

                        <p>



                        <p>
                            <input class="pxbtn" name="提 交" id="save-btn" type="button" value="用户提交">
                        </p>






                        <p>

                            <input name="" class="px" id="parssword" type="password" value="" placeholder="商家输入兑奖密码">
                        </p>

                        <p>
                            <input class="pxbtn" name="提 交" id="save-btnn" type="button" value="商家提交">
                        </p>
                    </div>
                </div>
            </div>
            <div class="boxcontent boxwhite">
                <div class="box">
                    <div class="title-red"><span>奖项设置：</span></div>

                    <div class="Detail">
                        <p>一等奖 ： 单反数码相机奖品数量：10 </p>
                        <p>二等奖 ： 20元抵用券 奖品数量：10  </p>
                        <p>三等奖 ： QQ公仔 奖品数量：10  </p>
                        <p>四等奖 ： nike运动鞋 奖品数量：10  </p>
                        <p>五等奖 ： 三星数码相机 奖品数量：10  </p>
                        <p>六等奖 ： ipad4代 奖品数量：10  </p>
                        <p>七等奖 ： lv提包奖品数量：10 </p>
                        <p>八等奖 ：  奖品数量：10  </p>
                    </div>
                </div>
            </div>
            <div class="boxcontent boxwhite">
                <div class="box">
                    <div class="title-red">活动说明：</div>
                    <div class="Detail">
                        <p class="red">本次活动每天可以转5次,总共可以转 100 次 你已经转了1次 </p>
                        <p>亲，请点击进入大转盘抽奖活动页面，祝您好运哦！（demo演示不要当真）  </p>
                    </div>
                </div>
            </div>
        </div>

    </div>


    <script type="text/javascript">


        $(function () {
            window.requestAnimFrame = (function () {
                return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
                function (callback) {
                    window.setTimeout(callback, 1000 / 60)
                }
            })();
            var totalDeg = 360 * 3 + 0;
            var steps = [];
            /*    var lostDeg = [36, 96, 156, 216, 276,336];
                var prizeDeg = [6, 66, 126,186,246,306];*/


            var lostDeg = [360];
            var prizeDeg = [40, 80, 120, 160, 200, 240, 280, 320];
            var prize, sncode;
            var count = 0;
            var now = 0;
            var a = 0.01;
            var outter, inner, timer, running = false;
            function countSteps() {
                var t = Math.sqrt(2 * totalDeg / a);
                var v = a * t;
                for (var i = 0; i < t; i++) {
                    steps.push((2 * v * i - a * i * i) / 2)
                }
                steps.push(totalDeg)
            }
            function step() {
               // alert('rotate(' + steps[now++] + 'deg)');
                outter.style.webkitTransform = 'rotate(' + steps[now++] + 'deg)';
                outter.style.MozTransform = 'rotate(' + steps[now++] + 'deg)';

                if (now < steps.length) {
                    running = true;
                    requestAnimFrame(step)
                } else {
                    running = false;
                    setTimeout(function () {
                        if (prize != null) {
                            $("#sncode").text(sncode);
                            var type = "";
                            if (prize == 1) {
                                type = "单反数码相机"
                            } else if (prize == 2) {
                                type = "20元抵用券"
                            } else if (prize == 3) {
                                type = "QQ公仔"
                            }
                            else if (prize == 4) {
                                type = "nike运动鞋"
                            }
                            else if (prize == 5) {
                                type = "三星数码相机"
                            }
                            else if (prize == 6) {
                                type = "ipad4代"
                            }
                            else if (prize == 7) {
                                type = "lv提包"
                            }
                            else if (prize == 8) {
                                type = ""
                            }
                            else if (prize == 9) {
                                type = ""
                            }
                            else if (prize == 10) {
                                type = ""
                            }
                            else if (prize == 11) {
                                type = ""
                            }
                            $("#prizetype").text(type);
                            $("#result").slideToggle(500);
                            $("#outercont").slideUp(500)
                        } else {
                            alert("亲，继续努力哦！")
                        }
                    },
                    200)
                }
            }

            function start(deg) {
              
                deg = deg || lostDeg[parseInt(lostDeg.length * Math.random())];
                running = true;
                clearInterval(timer);
                totalDeg = 360 * 5 + deg;
                steps = [];
                now = 0;
                countSteps();
                requestAnimFrame(step)
            }
            window.start = start;
            outter = document.getElementById('outer');
            inner = document.getElementById('inner');
            i = 10;
            $("#inner").click(function () {
                
                if (running) return;
                if (count >= 100) {
                    alert("您已经抽了 100 次奖,不能再抽了,下次再来吧!");
                    return
                }
                if (prize != null) {
                    alert("亲，你不能再参加本次活动了喔！下次再来吧~");
                    return
                }
                $.ajax({
                    url: "index.php",
                    dataType: "json",
                    data: {
                        token: "o7MB9jtqWGlltLePYaJim_Sg2hV0",
                        ac: "zhuanpanuser",
                        formhash: "7b12fa9a",
                        tid: "101",
                        t: Math.random()
                    },
                    beforeSend: function () {
                        running = true;
                        timer = setInterval(function () {
                            i += 5;
                          //  alert(i);
                            outter.style.webkitTransform = 'rotate(' + i + 'deg)';
                            outter.style.MozTransform = 'rotate(' + i + 'deg)'
                        },
                        1)
                    },
                    success: function (data) {
                        if (data.error == "invalid") {
                            alert(data.msg);
                            count = 100;
                            clearInterval(timer);
                            return
                        }
                        if (data.error == "getsn") {
                            alert(11);
                            $("#tel").val(data.tel);
                            if (data.state == 2) {
                                $("#closedj").css("display", "none");

                            }
                            $("#red").text(data.msg);
                            alert(data.msg + data.sn);
                            count = 100;
                            clearInterval(timer);
                            prize = data.prizetype;
                            sncode = data.sn;
                            start(prizeDeg[data.prizetype - 1]);
                            return
                        }
                        if (data.success) {
                          
                            prize = data.prizetype;
                            sncode = data.sn;
                            start(prizeDeg[data.prizetype - 1])
                        } else {
                          
                            prize = null;
                            start()
                        }
                        running = false;
                        count++
                    },
                    error: function () {
                        
                        prize = null;
                        start();
                        running = false;
                        count++
                    },
                    timeout: 1000
                })
            })
        });
        $("#save-btn").bind("click",
        function () {
            var btn = $(this);
            var tel = $("#tel").val();
            if (tel == '') {
                alert("请输入手机号");
                return
            }

            var submitData = {
                tid: 101,
                code: $("#sncode").text(),
                formhash: "7b12fa9a",
                tel: tel,
                action: "setTel"
            };
            $.post('index.php?ac=zhuanpanuser', submitData,
            function (data) {
                if (data.success == true) {
                    alert(data.msg);
                    return
                } else { }
            },
            "json")
        });

        $("#save-btnn").bind("click",
        function () {
            var submitData = {
                tid: 101,
                code: $("#sncode").text(),
                formhash: "7b12fa9a",
                parssword: $("#parssword").val(),
                action: "setps"
            };
            $.post('index.php?ac=zhuanpanuser', submitData,
            function (data) {
                if (data.success == true) {
                    alert(data.msg);
                    if (data.changed == true) {
                        window.location.href = location.href;
                    }
                    return
                } else { }
            },
            "json")
        });
    </script>
    <script type="text/javascript">
        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
            window.shareData = {
                "imgUrl": "",
                "timeLineLink": "http://www.apiwx.com?ac=zp&tid=101&id=650&c=o7MB9jtqWGlltLePYaJim_Sg2hV0&from=app&refwx=mp.weixin.qq.com",
                "sendFriendLink": "http://www.apiwx.com?ac=zp&tid=101&id=650&c=o7MB9jtqWGlltLePYaJim_Sg2hV0&from=app&refwx=mp.weixin.qq.com",
                "weiboLink": "http://www.apiwx.com?ac=zp&tid=101&id=650&c=o7MB9jtqWGlltLePYaJim_Sg2hV0&from=app&refwx=mp.weixin.qq.com",
                "tTitle": "幸运大转盘活动开始了（demo演示不要当真）",
                "tContent": "幸运大转盘活动开始了（demo演示不要当真）",
                "fTitle": "幸运大转盘活动开始了（demo演示不要当真）",
                "fContent": "幸运大转盘活动开始了（demo演示不要当真）",
                "wContent": "幸运大转盘活动开始了（demo演示不要当真）"
            };
            // 发送给好友
            WeixinJSBridge.on('menu:share:appmessage', function (argv) {
                WeixinJSBridge.invoke('sendAppMessage', {
                    "img_url": window.shareData.imgUrl,
                    "img_width": "640",
                    "img_height": "640",
                    "link": window.shareData.sendFriendLink,
                    "desc": window.shareData.fContent,
                    "title": window.shareData.fTitle
                }, function (res) {
                    _report('send_msg', res.err_msg);
                })
            });

            // 分享到朋友圈
            WeixinJSBridge.on('menu:share:timeline', function (argv) {
                WeixinJSBridge.invoke('shareTimeline', {
                    "img_url": window.shareData.imgUrl,
                    "img_width": "640",
                    "img_height": "640",
                    "link": window.shareData.timeLineLink,
                    "desc": window.shareData.tContent,
                    "title": window.shareData.tTitle
                }, function (res) {
                    _report('timeline', res.err_msg);
                });
            });

            // 分享到微博
            WeixinJSBridge.on('menu:share:weibo', function (argv) {
                WeixinJSBridge.invoke('shareWeibo', {
                    "content": window.shareData.wContent,
                    "url": window.shareData.weiboLink,
                }, function (res) {
                    _report('weibo', res.err_msg);
                });
            });
        }, false)
    </script>
</body>
</html>
